define(function(){
    var wanyiBase = wanyiBase || {};
    /**
     * [get cookie]
     * @param  {[type]} name [cookie name]
     * @return {[type]}      [cookie value]
     */
    wanyiBase.getCookie = function(name){
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return decodeURIComponent(arr[2]);
        } else {
            return null;
        }
    }

    /**
     * [set cookie]
     * @param {[type]} name  [cookie name]
     * @param {[type]} value [cookie value]
     * @param {[type]} time  [hour]
     */
    wanyiBase.setCookie = function(name,value,time) {　　
        var exp = new Date();　　
        exp.setTime(exp.getTime() + time * 60 * 60 * 1000); //有效期1小时    　　
        document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
    }

    /**
     * [delete cookie]
     * @param  {[type]} name [cookie name]
     * @return {[type]}      [description]
     */
    wanyiBase.delCookie = function(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = wanyiBase.getCookie(name);
        if (cval != null) {
            document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + "; path=/";
        }
    }
    return wanyiBase;
})


